Path: blob/master/Part 2 - Regression/Polynomial Regression/[Python] Polynomial Regression.ipynb
997 views
Polynomial Regression
Data Preprocessing
Problem Satement: So we are human resource team working for a big company and we are about to hire a new employee in this company so this new entry seems to be great a good fit for the job and we are about to make an offer to this potential new employee and now it's time to negotiate negotiate on what is going to be the future salary of this new employees in the company.
And so at the beginning of the negotiation to simpler is telling that he's had twenty plus years of experience and eventually earned 160K. annual salary in its previous company so this employee is asking for at least more than a 160K.
However there is someone in the H. R. team that is kind of a control freak and always fantasized about being a detective so suddenly decides to call the previous employer to check that info you know the info about the previous a 160K annual salary of this future potential new employee but unfortunately all the info that this person manages to get are these info here that is the symbol table of salaries for ten different positions in the previous company.
So there's a term member of the team runs a simple analysis on excel or Google sheets and actually observed that there is a non linear relationship between these position of old and their associated salaries.
However this HR person could get another very relevant info this all the relevant info is that this new employee has been a region manager for two years now and usually it takes on average four years to jump from being a region manager to a partner.
So this simply was kind of half way between level 6 and level 7 and therefore we can say he was level 6.5.
So now this HR guys getting all excited because he's selling to the team that he can build a blushing detector using regression models and predict if this new employees blushing about salary.
So at the beginning the team finds a little weird but it's kind of curious to see what's going to happen. And therefore here is the mission:
This new employee is telling that his annual salary was a 160K. Let's predict if it's truth or bluff by building a blushing detector using polynomial regression.
We can see the non-linear relationship between the Salary and Level
Fitting Linear Regression to the dataset
Fitting Polynomial Regression to the dataset
Visualising the Linear Regression results
Visualising the Polynomial Regression results
Polynomial Regression model with degree 3
Polynomial Regression model with degree 4
Get a more continuous curve
So X_grid contains 100 elements from 1 to 10 with step of 0.1
Predicting a new result with Linear Regression
Predicting a new result with Polynomial Regression
Since the result is 158K which is approximately equal to 160K, therefore the new emplyoee is not bluffing and he is honest.